package org.shj.pattern.simplefactory

trait Connection {
  def connect()
}

class MySql extends Connection{
  def connect(){
    println("connect to mysql")
  }
}

class Oracle extends Connection{
  def connect(){
    println("connect to Oracle")
  }
}

object Factory{
  def createConnection(dbtype: String) : Connection = {
    if("MySql" == dbtype){
      return new MySql()
    }else{
      return new Oracle
    }
  }
}